<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" th:href="@{/css/login.css}">
  <script type="text/javascript" th:src="@{/js/jquery-1.9.1.min.js}"></script>
  <script type="text/javascript" th:src="@{/js/utils.js}"></script>
  <title>登陆页面</title>
</head>
<body>
  <div class="container">
    <div class="login-form">
      <div class="text">登录</div>
      <div class="form-item">
        <input type="text" placeholder="用户名" id="username">
        <input type="password" placeholder="密码" id="password">
      </div>
      <div class="btn" onclick="login()">登录</div>
      <div class="btn-back"></div>
      <div class="other">
        没有账号？<a href="/register"target="_blank">注册</a>
      </div>
    </div>
  </div>

<div style="text-align:center;margin:50px 0; font:normal 14px/24px 'MicroSoft YaHei';">

</div>
</body>
<script th:inline="javascript" type="text/javascript">
function login(){
	$.ajax({
	    type: "get",//http://192.168.0.115/
	    url: "http://localhost:8080/login",
	// 		   data: "para="+para,  此处data可以为 a=1&b=2类型的字符串 或 json数据。
	    data: {
		"username":$("#username").val(),
		"password":$("#password").val()
	},
	    cache: false,
	    async : false,
        dataType: "JSON",
	    success: function (data ,textStatus, jqXHR)
	    {	
	    	 var result=data
	    	 if(result.code=="200"){
	    	 	window.location.href="/main";
	    	 }else{
	    	 	alert("没有这个用户哦~");
	    	 }
	    },
	    error:function (XMLHttpRequest, textStatus, errorThrown) {      
	       
	        alert(typeof(errorThrown));
	    }
	 });
}
</script>
</html>
